﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jumpton.SFA.Server.BusinessRule.System;
using System.Data;

public partial class Index : PageBase
{
    private object obj = null;

    protected void Page_Load(object sender, EventArgs e)
    {
       
        //Jumpton.Data.SqlData.OpenSql(" update [Version] set [VersionName]='1.0.4459.954'");
        //obj = new Jumpton.SFA.Server.BusinessRule.MasterData.PersonManager().Load(1);

        if (!IsPostBack)
        {

            lblName.InnerText = MyStateManager.Person_Name;
            lblDomain.InnerText = MyStateManager.DomainCode;
            

        }

    }

    List<string> modules = new List<string>();

    protected string LoadMenuItem()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
       
        sb.Append(" var _menus = {\"menus\":[\r\n");
        DataTable dt = new RoleManager().GetUserRole(MyStateManager.UserID,0);
        string TempModule = string.Empty;
        string Module = string.Empty;
        if (dt != null)
        {
            DataView dv = dt.DefaultView;
            for (int i = 0; i < dv.Count; i++)
            {
                if (!(modules.Contains(dv[i]["MODULE_NAME"].ToString())))
                {
                    if (modules.Count != 0)
                    {                       
                        //if (modules.Count == 11)
                        //    break;
                        sb.Append("]},");                        
                    }
                  
                    sb.Append("{\"menuid\":\"" + (i*100).ToString() + "\",\"icon\":\"icon-sys\",\"menuname\":\"" + dv[i]["MODULE_NAME"].ToString() + "\",");
                    modules.Add(dv[i]["MODULE_NAME"].ToString());
                    sb.Append("\"menus\":[");
                    sb.Append("{\"menuid\":\"" + (i + 1).ToString() + "\",\"menuname\":\"" + dv[i]["ITEM_NAME"].ToString() + "\",\"icon\":\"icon-nav\",\"url\":\"" + dv[i]["ITEM_LINK"].ToString() + "\"}\r\n");

                   

                    

                }
                else
                {
                    sb.Append(",{\"menuid\":\"" + (i + 1).ToString() + "\",\"menuname\":\"" + dv[i]["ITEM_NAME"].ToString() + "\",\"icon\":\"icon-nav\",\"url\":\"" + dv[i]["ITEM_LINK"].ToString() + "\"}\r\n");
                }
            }
           sb.Append("]}");
           sb.Append("]};");

        }

        return sb.ToString();
    }



    protected void Button1_Click(object sender, EventArgs e)
    {
        
    }
}
